﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate.Tool.hbm2ddl;
using Activity.Projeto.Infrastructure.FluentNHibernate.Mapping;
using NHibernate;

namespace Activity.Projeto.Infrastructure.FluentNHibernate
{
    public class SessionFactoryProvider
    {
        public static ISessionFactory CreateSessionFactory()
        {
            FluentConfiguration configuration = Fluently.Configure()
                .Database(MsSqlConfiguration.MsSql2008.ConnectionString(
                    x => x.FromConnectionStringWithKey("Connection")).ShowSql())
                .Mappings(x => x.FluentMappings.AddFromAssemblyOf<AtividadeMap>());

            return configuration.BuildSessionFactory();
        }
    }
}

